var newslistarr=[
    {
        url:'##',
        img:'img/img1.jpeg',
        name:'瑞典研究了1200位百岁老人：长寿者 多有这三个特点',
        user:'糖果果',
        time:'2023-10-10',
        pl:'2345',
        imglis:[
            'img/img1.jpeg',
            'img/img2.jpg',
            'img/img1.jpeg'
        ]
    },
    {
        url:'##',
        img:'img/img1.jpeg',
        name:'瑞典研究了1200位百岁老人：长寿者 多有这三个特点',
        user:'糖果果',
        time:'2023-10-10',
        pl:'2345',
        imglis:[]
    },
    {
        url:'##',
        img:'img/img1.jpeg',
        name:'瑞典研究了1200位百岁老人：长寿者 多有这三个特点',
        user:'糖果果',
        time:'2023-10-10',
        pl:'2345',
        imglis:[
            'img/img1.jpeg',
            'img/img2.jpg',
            'img/img1.jpeg'
        ]
    },
    {
        url:'##',
        img:'img/img1.jpeg',
        name:'瑞典研究了1200位百岁老人：长寿者 多有这三个特点',
        user:'糖果果',
        time:'2023-10-10',
        pl:'2345',
        imglis:[]
    }
]
// 加载文章数据
function getnews(device,obj,type) {
	var _this = $(obj);
    var html = '';
    if(type=='news'){  //文章列表
        if(device=="search"){
            $.each(newslistarr,function (index,item) {
                if(item.imglis.length>=1){
                    html+=`
                    <li class="li2">
                        <a href="${item.url}" class="box">
                           <div class="namebt">
                                <div class="icon num">${index}</div>
                                <div class="name">${item.name}</div>
                            </div>
                            <div class="infor">
                               ${item.imglis.map(img=>{
                                    return `<div class="img"><img class="lazy" src="${img}" alt=""></div>`
                                }).join('')}
                            </div>
                            <div class="bq">
                                <span>${item.user}</span>
                                <span><i class="icon icotime"></i>${item.time}</span>
                                <span><i class="icon icopl"></i>${item.pl}</span>
                            </div>
                        </a>
                    </li>
                `
                }else{
                    html+=`
                    <li>
                        <a href="${item.url}" class="box">
                            <div class="icon num">${index}</div>
                            <div class="infor">
                                <div class="name">${item.name}</div>
                                <div class="bq">
                                    <span>${item.user}</span>
                                    <span><i class="icon icotime"></i>${item.time}</span>
                                    <span><i class="icon icopl"></i>${item.pl}</span>
                                </div>
                            </div>
                            <div class="img"><img class="lazy" src="${item.img}" alt=""></div>
                        </a>
                    </li>`
                }
            })
        }else{
            $.each(newslistarr,function (index,item) {
                if(item.imglis.length>=1){
                    html+=`
                    <li class="li2">
                        <a href="${item.url}" class="box">
                           <div class="name">${item.name}</div>
                            <div class="infor">
                               ${item.imglis.map(img=>{
                                    return ` <div class="img"><img class="lazy" src="${img}" alt=""></div>`
                                }).join('')}
                            </div>
                            <div class="bq">
                                <span>${item.user}</span>
                                <span><i class="icon icotime"></i>${item.time}</span>
                                <span><i class="icon icopl"></i>${item.pl}</span>
                            </div>
                        </a>
                    </li>
                `
                }else{
                    html+=`
                    <li>
                        <a href="${item.url}" class="box">
                            <div class="img"><img class="lazy" src="${item.img}" alt=""></div>
                            <div class="infor">
                                <div class="name">${item.name}</div>
                                <div class="bq">
                                    <span>${item.user}</span>
                                    <span><i class="icon icotime"></i>${item.time}</span>
                                    <span><i class="icon icopl"></i>${item.pl}</span>
                                </div>
                            </div>
                        </a>
                    </li>`
                }
            })
        }
    }else if(type=='down'){  //下载列表
        $.each(newslistarr,function (index,item) {
            html+=`
            <li>
                <a href="${item.url}" class="box">
                    <div class="img"><img class="lazy" src="${item.img}" alt=""></div>
                    <div class="flex1">
                        <div class="name">${item.name}</div>
                        <p>你感兴趣的视频都在B站</p>
                    </div>
                    <div class="btn">下载</div>
                </a>
            </li>`
        })
    }else if(type=='video'){
        $.each(newslistarr,function (index,item) { 
            html+=`
                <li>
                    <a href="##" class="img"><img  src="img/lunbox1.jpg" alt=""></a>
                    <div class="flex1">
                    <a href="##" class="name">孤注一掷（2023）</a>
                        <div class="tab_p">
                            <div class="tab cor3">电影</div>
                        </div>
                        <p>中国大陆 / 剧情 / 犯罪 </p>
                        <p>张艺兴 / 金晨 / 王传君 / 王大陆</p>
                        <a href="##" class="btn">去看看</a>
                    </div>
                </li>
             `
         })
    }
    _this.parents(".list").find("ul").append(html)
}

function getmoredevice(type,obj,device) {
    var time= setTimeout(() => {
            getnews(type,obj,device);
            clearTimeout(time)
        }, 500);
}
